package day02.connection;

import day02.db.DataSource;

import java.sql.Connection;
import java.sql.DriverManager;

public class UserConnection {

    private UserConnection(){}

    public static Connection getConnection(DataSource dataSource) {
        Connection connection = null;
        try {
            Class.forName(dataSource.getDriver());
            connection = DriverManager.getConnection(dataSource.getUrl(), dataSource.getRoot(), dataSource.getPassword());
        } catch (Exception e) {
            e.printStackTrace();
        }
        finally {
            return connection;
        }

    }
}
